package com.cet.designpatterns.prototype.深拷贝;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-09-06 16:29
 **/
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        DeepProtoType deepProtoType = new DeepProtoType();
        deepProtoType.setName("宋江");
        deepProtoType.setTarget(new DeepCloneableTarget("大牛","人类"));

        //方式1完成深拷贝
//        DeepProtoType p2 = (DeepProtoType) deepProtoType.clone();
//        System.out.println(deepProtoType.getTarget() == p2.getTarget());

        //方式2完成深拷贝
        DeepProtoType p3 = (DeepProtoType) deepProtoType.deepClone();
        System.out.println(deepProtoType.getTarget() == p3.getTarget());
    }
}
